var router = require('express').Router();
var { XiaoHuoModel } = require('../dbs/dbXiaoHuo');
// 获取表数据的
router.use(function(req, res, next) {
  let { query } = req.query;
  if (query === 'all') {
    (async function() {
      // 获取所有的表信息
      let allFind = await XiaoHuoModel.find({}).catch(err => {
        res.json({ code: 0, msg: '服务器出错' });
      });
      if (allFind) {
        res.json({ code: 1, mag: '获取成功', data: allFind });
      } else {
        res.json({ code: 0, mag: '获取失败' });
      }
    })();
  } else {
    next();
  }
});

module.exports = router;
